feat(ws): support enableReceivedNotification in SignatureSubscribe#432
Open
ozpool wants to merge 1 commit into
Open
feat(ws): support enableReceivedNotification in SignatureSubscribe#432ozpool wants to merge 1 commit into
ozpool wants to merge 1 commit into
Conversation
Add SignatureSubscribeWithOpts and SignatureSubscribeOpts, mirroring the
optional configuration object the signatureSubscribe RPC method accepts.
EnableReceivedNotification opts the subscription into the additional
"received" notification the validator emits as soon as the transaction
enters its mempool, in addition to the final status notification.
The notification value can now arrive as either a status object
({"err": ...}) or the literal string "receivedSignature". A new
SignatureValue named type with a custom UnmarshalJSON dispatches on
JSON shape so the existing result.Value.Err access keeps working and
the new ReceivedSignature field surfaces the marker variant. The
existing SignatureSubscribe entry point delegates to the new opts
form, preserving its (signature, commitment) signature.
Adds unit coverage for both notification shapes, the null/empty case,
and an unknown-marker rejection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SignatureSubscribeWithOpts+SignatureSubscribeOptsto mirror the optional configuration object thesignatureSubscribeRPC method accepts, including the missingenableReceivedNotificationflag.When
enableReceivedNotification: true, the validator emits an extra notification withvalue: "receivedSignature"as soon as the transaction enters its mempool, in addition to the finalvalue: { err: ... }status notification. Today the SDK can't ask for that flag and theSignatureResult.Valuestruct can't decode the string variant if the user enables it on the RPC side themselves.What changed
SignatureResult.Valueis now a namedSignatureValuewith a customUnmarshalJSONthat dispatches on the wire shape:{"err": ...}-> populatesErr"receivedSignature"-> setsReceivedSignature = truenullis treated as a no-opSignatureSubscribeOpts { Commitment, EnableReceivedNotification }plusSignatureSubscribeWithOpts(signature, opts)carry the new flag through to the request body.SignatureSubscribe(signature, commitment)entry point is preserved by delegating to the new opts form, andresult.Value.Erraccess continues to work unchanged.Test plan
go build ./...go test ./...signatureSubscribe_test.gocovers: status witherr: null, status with non-nullerr,"receivedSignature"string variant, unknown-marker rejection,nullno-op